﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Tutorials;
using Lxzhu.OpenGL;
namespace Tutorials
{
    class Program:TimedGlutEngine
    {
        static void Main(string[] args)
        {
            Program rt = new Program() { Title = "PrimitiveLines", Interval=1000};
            rt.Run();
        }
        public override void OnDisplay()
        {
            Gl.glClear(BufferBit.GL_COLOR_BUFFER_BIT);
            Gl.glClearColor(0, 0, 0, 0);
            Gl.glLineWidth(5);
            Gl.glEnable(Gl.GL_LINE_SMOOTH);
            Gl.glEnable(Capability.GL_LINE_STIPPLE);
            Gl.glLineWidth(1);
            Gl.glLineStipple(1, LineStyle.Solid);
            glBegin();
            Gl.glColor(1, 0, 0);
            Gl.glVertex(-0.4f, -0.4f);
            Gl.glColor(1, 1, 0);
            Gl.glVertex(-0.5f, 0);
            Gl.glColor(1, 1, 1);
            Gl.glVertex(-0.4f, .4f);
            Gl.glColor(0, 1, 1);
            Gl.glVertex(-0.3f, 0);
            Gl.glEnd();

            Gl.glLineStipple(1, LineStyle.Dotted);
            glBegin();
            Gl.glColor(1, 0, 0);
            Gl.glVertex(-0.15f, -0.4f);
            Gl.glColor(1, 1, 0);
            Gl.glVertex(-0.25f, 0);
            Gl.glColor(1, 1, 1);
            Gl.glVertex(-0.15f, .4f);
            Gl.glColor(0, 1, 1);
            Gl.glVertex(-0.05f, 0);
            Gl.glEnd();

            Gl.glLineStipple(1, LineStyle.Dashed);
            glBegin();
            Gl.glColor(1, 0, 0);
            Gl.glVertex(0.1f, -0.4f);
            Gl.glColor(1, 1, 0);
            Gl.glVertex(0f, 0f);
            Gl.glColor(1, 1, 1);
            Gl.glVertex(0.1f, .4f);
            Gl.glColor(0, 1, 1);
            Gl.glVertex(.2f, 0f);
            Gl.glEnd();

            Gl.glLineStipple(1, LineStyle.DashDotDash);
            glBegin();
            Gl.glColor(1, 0, 0);
            Gl.glVertex(.35f, -0.4f);
            Gl.glColor(1, 1, 0);
            Gl.glVertex(.25f, 0f);
            Gl.glColor(1, 1, 1);
            Gl.glVertex(.35f, .4f);
            Gl.glColor(0, 1, 1);
            Gl.glVertex(.45f, 0f);
            Gl.glEnd();

            
        }
        private void glBegin()
        {
            switch (this.TotalFrames % 3)
            {
                case 0: Gl.glBegin(PrimitiveType.GL_LINES); break;
                case 1: Gl.glBegin(PrimitiveType.GL_LINE_STRIP); break;
                case 2: Gl.glBegin(PrimitiveType.GL_LINE_LOOP); break;
            }
        }
       
    }
}
